package Control;
import javax.swing.*;
import java.awt.*;
import java.text.*;

public class Receipt extends JFrame
{
        private JTextArea receipt;
        private java.util.Date date;
        
        public Receipt(Double subtotal, Double cash)
        {
                super("Receipt");
                setSize(235, 215);
                setResizable(false);
                setLocationRelativeTo(null);
                setDefaultCloseOperation(DISPOSE_ON_CLOSE);
                receipt = new JTextArea();
                receipt.setEditable(false);
                date = new java.util.Date();
                SimpleDateFormat sdf = new SimpleDateFormat(" dd/MM/yyyy HH:mm:ss");
                int points = subtotal.intValue() / 25;
                
                DecimalFormat nf = new DecimalFormat("0.00");
                double change = cash - subtotal;
                
                receipt.setText("\n\t  MDL Systems\n\n\n Subtotal \t\t € " +nf.format(subtotal)+ 
                							" \n Cash \t\t\t € " +nf.format(cash)+ " \n Change \t\t € " +nf.format(change)+
                							"\n Points \t\t    " + points +
                							"\n\n\n     " + sdf.format(date) + " \n  Thank you for your service! \n    Please visit again soon");
                receipt.setFont(new Font("Courier New", Font.BOLD, 12));
                
                this.add(receipt);
        }
        
        public static void main(String[] args)
        {
                Receipt rp = new Receipt(50.00, 50.00);
                rp.setVisible(true);
        }
}